package com.xdh.zzqh.ui.view

import android.annotation.SuppressLint
import java.math.BigDecimal
import java.math.RoundingMode

class Order(
    val type: String,
    val style: String,
    val spec: String,
    val dir: String,
    val left: Int,
    val right: Int,
    val price: BigDecimal,
    val hands: String,
    val color: String,
    val remark: String,
    private val dis: String, // 打折
    private val dis2: String, // 扣减
) {

    @SuppressLint("DefaultLocale")
    fun allPrice(): String {
        val num =  left + right

        try {
            var pp = price
            if (dis.isNotEmpty()) {
                pp = pp.multiply(BigDecimal(dis)).div(BigDecimal(10))
            }
            if (dis2.isNotEmpty()) {
                pp = pp.subtract(BigDecimal(dis2))
            }
            pp = pp.multiply(BigDecimal(num))
            pp.setScale(2, RoundingMode.HALF_UP)
            return pp.toString()
        } catch (e: Exception) {
            e.printStackTrace()
        }

        val r = price.multiply(BigDecimal(num))
        return r.toString()
    }
}

